<cfparam name="cartID" default="createUUID()">

<cfif not structKeyExists(session,"GoogleCart") or structkeyexists(url,"reinit")>
	<cfset session.GoogleCart =  createObject("component","googleCheckOut")>

	<!--- Just add some items to the cart to get us going --->
	<cfset session.GoogleCart.AddCartItem(item="3432511",description="New Widget",cost="210",quantity="4")>
	<cfset session.GoogleCart.AddCartItem(item="34242",description="Last years Widget",cost="13.70",quantity="1")>
	<cfset session.GoogleCart.AddCartItem(item="191911",description="Accessories for Widget",cost="24.00",quantity="3")>
</cfif>

<!--- sample clear cart ---->
<cfif structkeyexists(url,"emptycart")>
	<cfset session.GoogleCart.emptyCart()>
</cfif>

<!--- sample remove item from cart ---->
<cfif structkeyexists(url,"removeitem")>
	<cfset session.GoogleCart.removeCartItem(url.removeitem)>
</cfif>

<!--- Loop over form submission and update the cart quanity --->
<cfif structkeyExists(form,"fieldnames")>
	<cfloop list="#form.FIELDNAMES#" index="theField">
		<cfif thefield neq 'Update'>
			<cfset session.GoogleCart.UpdateCartItem(item="#theField#",quantity=#evaluate("form.#theField#")#)>
		</cfif>
	</cfloop>	
</cfif>




<!--- Create default cart to show how
I already added these items up top but this is how you would add your shopping carts items to the CFC

If your cart items were in a query called foo, you would do this:
<cfoutput query="foo">
	<cfset session.GoogleCart.AddCartItem(item='#YourItemID#',description='#Your Description#',cost='#yourCost#',quantity='#YourQTY#')>
</cfoutput>	
 ---->
<cfif structkeyexists(url,"newcart")>
	<cfset session.GoogleCart.AddCartItem(item="TC",description="This is tuition",cost="210",quantity="4")>
	<cfset session.GoogleCart.AddCartItem(item="FE",description="This is a fee",cost="13.70",quantity="1")>
	<cfset session.GoogleCart.AddCartItem(item="AD",description="This is an adjustment",cost="24.00",quantity="3")>
</cfif>

<cfif structkeyexists(url,"AddItem")>
	<cfset session.GoogleCart.AddCartItem(item="TC",description="New Widget",cost="210",quantity="1")>
</cfif>


<!--- Get the cart contents ---->
<cfset Cart = session.GoogleCart.GetCartItems()>

Your Cart Contents:
<form action="<cfoutput>#cgi.script_name#</cfoutput>" method="post">
<table width="600"  cellpadding=1 cellspacing=1 border=1 class="top_sm_bar" style="border:1px solid #000000; border-collapse: collapse;empty-cells: show;vertical-align:top;margin-left:10px;">
		<tr style="background:#f1f1f1;color:black;">
			<td align="center">Quantity</td>
			<td>Item</td>
			<td align="right">Price</td>
			<td align="right">Total</td>
			<td>Actions</td>
		</tr>	

	<cfoutput query="Cart">
		<tr>
			<td align="center"><input type="text" name="#itemname#" value="#itemquantity#" size="2"></td>
			<td>#ITEMDESC#</td>
			<td align="right">#dollarformat(itemprice)#</td>
			<td align="right">#dollarformat(total)#</td>
			<td>(<a href="#cgi.script_name#?removeitem=#itemname#">remove</a>)</td>
		</tr>	
	</cfoutput>
</table>
	<cfif cart.recordcount>
		<input type="submit" name="Update" value="Update Quantity">
	</cfif>	
</form>
<br>

<!--- Output the checkout button --->
	<cfif cart.recordcount>
		<div align="right" style="width:600;">
			<Cfoutput>#session.googleCart.CreateForm()#</cfoutput>	
		</div>
	</cfif>	


<!---
	<CFDUMP var="#session.GoogleCart.getCartItems()#">
--->